iT邦幫忙

2025 iThome 鐵人賽

DAY 19
0
自我挑戰組

cpe30天練習系列 第 19

cpe練習day19

  • 分享至 

  • xImage
  •  

今天是練習cpe的Hashmat the Brave Warrior題目

程式碼

#include <bits/stdc++.h>
using namespace std;

int main()
{
	long x;
	long y;
	while(cin >>x >> y)
	{
		cout << abs(x - y) << endl; 
	}
   return 0;
}

解題方向

  • long x;long y; -> 兩個變數x和y,類型為long。這個資料類型是用在儲存大於標準int能容納的整數
  • cout << abs(x - y) << endl; -> 有可能是負的所以要加abs確保值是正的

上一篇
cpe練習day18
系列文
cpe30天練習19
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言